package cn.hx.SpringBoot_Jsp.controller;

import cn.hx.SpringBoot_Jsp.model.Student;
import cn.hx.SpringBoot_Jsp.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @类功能说明：
 * @公司名称：南京华讯方舟通讯设备有限公司
 * @作者：zhoujinbing
 * @创建时间：2018/9/18 9:25
 * @版本：V1.0
 */
@Controller
public class IndexController {

    @Autowired
    private StudentRepository studentRepository;

    /**
     * @description 整合跳转jsp页面
     * @method  index
     * @param  [map]
     * @return java.lang.String
     * @date: 2018/9/18 14:06
     * @author:zhoujinbing
     */
    @GetMapping("/index")
    public String index(ModelMap map)
    {
        Student stu = studentRepository.findById(1L).get();
        map.put("student",stu);
        System.out.println("进入根目录");
        return "jsp/index";
    }

    /**
     * @description 整合跳转Thymeleaf模版引擎
     * @method  indexHtml
     * @param  [map]
     * @return java.lang.String
     * @date: 2018/9/18 14:07
     * @author:zhoujinbing
     */
    @GetMapping("/hello")
    public String indexHtml(ModelMap map)
    {
        Student stu = studentRepository.findById(1L).get();
        map.put("student",stu);
        return "templates/hello";
    }

}
